{extend name="public/base" /}
{block name="head"}
    <meta charset="UTF-8">
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <link href="/resource/ui-framework/easyui-1.5.2/themes/metro/easyui-c5a176a3d4.css" rel="stylesheet" />
    <link href="/resource/ui-framework/easyui-1.5.2/themes/icon-77a4ded0c8.css" rel="stylesheet" />

    <link href="/resource/ui-framework/bootstrap/3.0.3/css/bootstrap-a067b6d831.min.css" rel="stylesheet" />
    <link href="/resource/ui-framework/bootstrap-daterangepicker/css/daterangepicker-886dba62c4.css" rel="stylesheet" />
    <link href="/resource/ui-framework/font-awesome/css/font-awesome-a81d284b37.css" rel="stylesheet" />

    <link href="/resource/ui-framework/admin-lte/css/AdminLET-7d58b99a7e.css" rel="stylesheet" />
    <link href="/static/css/base-dc47892812.css" rel="stylesheet" />

    <link href="/resource/ui-framework/jason/searchbox/css/searchbox-398327fb84.css" rel="stylesheet" />
    <link href="/resource/ui-framework/jason/pager/css/pager-f077f5e880.css" rel="stylesheet" />
    <link href="/resource/ui-framework/jason/status/css/status-5f59ab3856.css" rel="stylesheet" />
    <link href="/resource/ui-framework/jason/selector/css/selector-23060c280e.css" rel="stylesheet" />
    <link href="/resource/ui-framework/jason/button/css/button-5ef10c798a.css" rel="stylesheet" />
    <link href="/resource/ui-framework/jason/orderarrow/css/orderarrow-dcf8eba7d1.css" rel="stylesheet" />

    <link href="/static/css/table-0e491bc98f.css" rel="stylesheet" />
    <link href="/static/css/easyui-ext-372f902530.css" rel="stylesheet" />

{/block}
{block name="content"}
<section class="content">
<div class="container" style="width:50%;">
    <div class="row">
        <div class="col-md-12">
            <div class="border mt20 fl" id="addPanel" style="width:500px">
                <div class="minor-title">请填写以下帐号信息：</div>
                <ul class="add-list filter-box"> 
                    <li class="clearfix">
                        <div class="items fl">手机号：</div>
                        <div class="fill-items fl">
                            <input type="text" class="textbox-text" autocomplete="off" style="margin: 0px;border:1px solid grey; padding-top: 0px; padding-bottom: 0px; height: 24px; line-height: 24px; width: 129px;" name="mobile">
                        </div>
                    </li>
                    <li class="clearfix">
                        <div class="items fl">姓名：</div>
                        <div class="fill-items fl">
                            <input type="text" class="textbox-text" autocomplete="off" style="margin: 0px;border:1px solid grey; padding-top: 0px; padding-bottom: 0px; height: 24px; line-height: 24px; width: 129px;" name="name">
                        </div>
                    </li>
                    <li class="clearfix">
                        <div class="items fl">密码：</div>
                        <div class="fill-items fl">
                            <input type="text" class="textbox-text" autocomplete="off" style="margin: 0px;border:1px solid grey; padding-top: 0px; padding-bottom: 0px; height: 24px; line-height: 24px; width: 129px;" name="password">
                        </div>
                    </li>
                    <li class="clearfix">
                        <div class="items fl"></div>
                        <div class="fill-items fl">
                            <span style="color:red">* 密码可以不填写，默认123456</span>           
                        </div>
                    </li>
                    <li class="clearfix">
                        <div class="items fl">岗位：</div>
                        <div class="fill-items fl">
                            <select class="easyui-combobox" name="group_id" style="height: 24px; line-height: 24px;width: 131px;border:1px solid grey">
                                    {volist name="group" id="vo"}
                                    <option value="{$vo.id}">{$vo.title}</option>
                                    {/volist}
                            </select>                                
                        </div>
                    </li> 
                    <li class="clearfix">
                        <div class="items fl">限制IP：</div>
                        <div class="fill-items fl">
                            <input type="text" class="textbox-text" autocomplete="off" style="margin: 0px;border:1px solid grey; padding-top: 0px; padding-bottom: 0px; height: 24px; line-height: 24px; width: 129px;" name="limit_ip">             
                        </div>
                    </li>
                    <li class="clearfix">
                        <div class="items fl"></div>
                        <div class="fill-items fl">
                            <span style="color:red">* 限制IP，是指限制该账号只能在具有指定IP的网络中登录</span>           
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <div class="border mt20 fl" style="width:500px">
                <div class="minor-title">请填写以下用户信息：</div>
                <ul class="add-list filter-box">                    
                    <li class="clearfix">
                        <div class="items fl">年龄：</div>
                        <div class="fill-items fl">
                            <input type="text" class="textbox-text" autocomplete="off" style="margin: 0px;border:1px solid grey; padding-top: 0px; padding-bottom: 0px; height: 24px; line-height: 24px; width: 129px;" name="age" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
                        </div>
                    </li>                       
                    <li class="clearfix">
                        <div class="items fl">QQ：</div>
                        <div class="fill-items fl">
                            <input type="text" class="textbox-text" autocomplete="off" style="margin: 0px;border:1px solid grey; padding-top: 0px; padding-bottom: 0px; height: 24px; line-height: 24px; width: 129px;" name="qq" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
                        </div>
                    </li>
                    <li class="clearfix">
                        <div class="items fl">微信号：</div>
                        <div class="fill-items fl">
                            <input type="text" class="textbox-text" autocomplete="off" style="margin: 0px;border:1px solid grey; padding-top: 0px; padding-bottom: 0px; height: 24px; line-height: 24px; width: 129px;" name="wechat">
                        </div>
                    </li>        
                </ul>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <ul class="add-list filter-box">
                <li>
                    <div class="items fl"></div>
                    <div class="fill-items fl mt10" style="margin-left:0px">
                        <a onclick="btnAddUser()" class="btn-action">提交</a>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>
</section>
   {/block}
{block name="script"}
<script src="/resource/libs/jquery/jquery.js"></script>
<script src="/static/js/layer/layer.js"></script>
<script type="text/javascript">
    $().ready(function () {
        var url = $('#hdnURL').val();
        $('.sidebar .treeview').each(function (index, item) {
            var btn = $(this).children("a").first();
            var menu = $(this).children(".treeview-menu").first();
            $(this).find('a').each(function (index, item) {
                if ($(item).attr('href') == url) {
                    menu.show();
                    btn.children(".fa-angle-left").first().removeClass("fa-angle-left").addClass("fa-angle-down");
                }
            });
        });
    });
    function btnAddUser(){
        var name = $("input[name=name]").val();
        var mobile = $("input[name=mobile]").val();
        var password = $("input[name=password]").val();
        var group_id = $("select[name=group_id]").val();
        var limit_ip = $("input[name=limit_ip]").val();
        var age = $("input[name=age]").val();
        var qq = $("input[name=qq]").val();
        var wechat = $("input[name=wechat]").val();
        if(isPhoneNo($.trim(mobile)) == false) {
            layer.msg('手机号码格式错误');
            return false;
        }
        if(!$.trim(name)) {
            layer.msg('请输入姓名');
            return false;
        }
        if( $.trim(limit_ip) && checkIP($.trim(limit_ip)) == false) {
            layer.msg('ip格式错误');
            return false;
        }
        $.post('/index/user/add',{name:name,mobile:mobile,password:password,group_id:group_id,limit_ip:limit_ip,age:age,qq:qq,wechat:wechat},function(res){
            layer.msg(res.msg);
            if(res.code == 1){
                window.setTimeout(function(){
                    window.location.href='/index/user/staff';
                },1000);
            }
        });
    }
    // 验证手机号
    function isPhoneNo(phone) { 
     var pattern = /^1[34578]\d{9}$/; 
     return pattern.test(phone); 
    }
    //判断ip地址的合法性
    function checkIP(value){
        var exp=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
        var reg = value.match(exp);
        if(reg==null)
        {
        return false;
        }
    }
</script>
{/block}  